// SelectRBWDlg.cpp : implementation file
//

#include "stdafx.h"
#include "signalanalyzer.h"
#include "SelectRBWDlg.h"
#include "InputNumDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSelectRBWDlg dialog


CSelectRBWDlg::CSelectRBWDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSelectRBWDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSelectRBWDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CSelectRBWDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSelectRBWDlg)
	DDX_Control(pDX, IDC_LST_RBW, m_lst_rbw);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSelectRBWDlg, CDialog)
	//{{AFX_MSG_MAP(CSelectRBWDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSelectRBWDlg message handlers

BOOL CSelectRBWDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString rbwStr;
	int baseRBW = 25;
	for (int i = 0; i< 10; i++){
		rbwStr.Format("%dKHZ", baseRBW*(i+1));
		m_lst_rbw.AddString(rbwStr);
	}
	m_lst_rbw.SetItemHeight(0, 22);
	m_lst_rbw.SetCurSel(
		AfxGetApp()->GetProfileInt(PROFILE_SECTION, GetEntryStr(IDC_BUTTON_RBW) + PROFILE_ENTRY_INDEX_SUFFIX, DEFAULT_RBW_INDEX)
	);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSelectRBWDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString selectedRBW;
	m_lst_rbw.GetText(m_lst_rbw.GetCurSel(), selectedRBW);

	AfxGetApp()->WriteProfileInt(PROFILE_SECTION, GetEntryStr(IDC_BUTTON_RBW) + PROFILE_ENTRY_INDEX_SUFFIX, m_lst_rbw.GetCurSel());
	AfxGetApp()->WriteProfileString(PROFILE_SECTION, GetEntryStr(IDC_BUTTON_RBW) + PROFILE_ENTRY_NAME_SUFFIX, selectedRBW);
	
	CDialog::OnOK();
}
